home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / examples / crabs / part01
Encoding:
Internet Message Format  |  1990-08-17  |  35.2 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i226: crabs - crustaceans consume your console, Part01/01
  4. Reply-To: thyssen@batserver.cs.uq.oz.au (Anthony Thyssen)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i226@abcfd20.larc.nasa.gov>
  7. Date: 17 Aug 90 18:39:31 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga
  11.  
  12. Submitted-by: thyssen@batserver.cs.uq.oz.au (Anthony Thyssen)
  13. Posting-number: Volume 90, Issue 226
  14. Archive-name: examples/crabs/part01
  15.  
  16. [ uuencoded executable, bitmaps, and icons included  ...tad ]
  17.  
  18. This program is a hack I wanted to do for the amiga after seeing
  19. an article about crabs in Scientific American. The program is my own
  20. and is different to the original idea in that the crabs reproduce.
  21. The source is included and is a good example of hacking the main
  22. workbench screen directly
  23.  
  24. #!/bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of archive 1 (of 1)."
  31. # Contents:  .info.uu blob blobmask crab16.uu crab8 crabmask16.uu
  32. #   crabmask8 crabs.c crabs.h crabs.info.uu crabs.uu intergerize.c
  33. #   makefile merge.c rotate.c
  34. # Wrapped by tadguy@abcfd20 on Fri Aug 17 14:39:29 1990
  35. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  36. if test -f '.info.uu' -a "${1}" != "-c" ; then 
  37.   echo shar: Will not clobber existing file \"'.info.uu'\"
  38. else
  39. echo shar: Extracting \"'.info.uu'\" \(66 characters\)
  40. sed "s/^X//" >'.info.uu' <<'END_OF_FILE'
  41. Xbegin 644 .info
  42. X6\TP`$@``$2D```+-```*X&-R86)S"@``9
  43. X``
  44. Xend
  45. Xsize 22
  46. END_OF_FILE
  47. if test 66 -ne `wc -c <'.info.uu'`; then
  48.     echo shar: \"'.info.uu'\" unpacked with wrong size!
  49. fi
  50. # end of '.info.uu'
  51. fi
  52. if test -f 'blob' -a "${1}" != "-c" ; then 
  53.   echo shar: Will not clobber existing file \"'blob'\"
  54. else
  55. echo shar: Extracting \"'blob'\" \(78 characters\)
  56. sed "s/^X//" >'blob' <<'END_OF_FILE'
  57. X............
  58. X....****....
  59. X..********..
  60. X..********..
  61. X....****....
  62. X............
  63. END_OF_FILE
  64. if test 78 -ne `wc -c <'blob'`; then
  65.     echo shar: \"'blob'\" unpacked with wrong size!
  66. fi
  67. # end of 'blob'
  68. fi
  69. if test -f 'blobmask' -a "${1}" != "-c" ; then 
  70.   echo shar: Will not clobber existing file \"'blobmask'\"
  71. else
  72. echo shar: Extracting \"'blobmask'\" \(78 characters\)
  73. sed "s/^X//" >'blobmask' <<'END_OF_FILE'
  74. X...******...
  75. X.**********.
  76. X************
  77. X************
  78. X.**********.
  79. X...******...
  80. END_OF_FILE
  81. if test 78 -ne `wc -c <'blobmask'`; then
  82.     echo shar: \"'blobmask'\" unpacked with wrong size!
  83. fi
  84. # end of 'blobmask'
  85. fi
  86. if test -f 'crab16.uu' -a "${1}" != "-c" ; then 
  87.   echo shar: Will not clobber existing file \"'crab16.uu'\"
  88. else
  89. echo shar: Extracting \"'crab16.uu'\" \(572 characters\)
  90. sed "s/^X//" >'crab16.uu' <<'END_OF_FILE'
  91. Xbegin 644 crab16
  92. XM+BXN+BXN+BXN+BXN+BXN+@HN+BXN+BXN+BXN+BXN+BXN"BXN+BXJ*BXN+BXJ"
  93. XM*BXN+BX*+BXN*BHJ+BXN+BHJ*BXN+@HN+BXJ*BXN+BXN+BHJ+BXN"BXN*BXNZ
  94. XM+BHN+BHN+BXJ+BX*+BXJ+BXN*BHJ*BXN+BHN+@HN+BXJ*BHJ*BHJ*BHJ+BXN"
  95. XM"BXN+BXN*BHJ*BHJ+BXN+BX*+BXJ*BHJ*BHJ*BHJ*BHN+@HN*BXN+BHJ*BHJ*
  96. XM*BXN+BHN"BXN+BXJ+BHJ*BHN*BXN+BX*+BXN*BXN+BXN+BXN*BXN+@HN+BXJ^
  97. XM*BXN+BXN+BHJ+BXN"BXN+BXN+BXN+BXN+BXN+BX*+BXN+BXN+BXN+BXN+BXN"
  98. XM+@H:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:6
  99. XM&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:2
  100. X8&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:P
  101. X``
  102. Xend
  103. Xsize 384
  104. END_OF_FILE
  105. if test 572 -ne `wc -c <'crab16.uu'`; then
  106.     echo shar: \"'crab16.uu'\" unpacked with wrong size!
  107. fi
  108. # end of 'crab16.uu'
  109. fi
  110. if test -f 'crab8' -a "${1}" != "-c" ; then 
  111.   echo shar: Will not clobber existing file \"'crab8'\"
  112. else
  113. echo shar: Extracting \"'crab8'\" \(110 characters\)
  114. sed "s/^X//" >'crab8' <<'END_OF_FILE'
  115. X..........
  116. X..**.***..
  117. X.****.***.
  118. X.*......*.
  119. X.*.****.*.
  120. X..******..
  121. X..******..
  122. X.********.
  123. X..*....*..
  124. X..........
  125. END_OF_FILE
  126. if test 110 -ne `wc -c <'crab8'`; then
  127.     echo shar: \"'crab8'\" unpacked with wrong size!
  128. fi
  129. # end of 'crab8'
  130. fi
  131. if test -f 'crabmask16.uu' -a "${1}" != "-c" ; then 
  132.   echo shar: Will not clobber existing file \"'crabmask16.uu'\"
  133. else
  134. echo shar: Extracting \"'crabmask16.uu'\" \(576 characters\)
  135. sed "s/^X//" >'crabmask16.uu' <<'END_OF_FILE'
  136. Xbegin 644 crabmask16
  137. XM+BXN+BXN+BXN+BXN+BXN+@HN+BXN*BHJ+BXJ*BHN+BXN"BXN*BHJ*BHJ*BHJ2
  138. XM*BHJ+BX*+BXJ*BHJ*BHJ*BHJ*BHN+@HN*BHJ*BHJ*BHJ*BHJ*BHN"BXJ*BHJF
  139. XM*BHJ*BHJ*BHJ*BX*+BHJ*BHJ*BHJ*BHJ*BHJ+@HN+BHJ*BHJ*BHJ*BHJ*BXN^
  140. XM"BXN*BHJ*BHJ*BHJ*BHJ+BX*+BHJ*BHJ*BHJ*BHJ*BHJ+@HN*BHJ*BHJ*BHJ>
  141. XM*BHJ*BHN"BXJ*BHJ*BHJ*BHJ*BHJ*BX*+BXJ*BHJ*BHJ*BHJ*BHN+@HN+BHJF
  142. XM*BHJ*BHJ*BHJ*BXN"BXN+BXJ*BHN+BHJ*BXN+BX*+BXN+BXN+BXN+BXN+BXN.
  143. XM+@H:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:6
  144. XM&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:2
  145. X8&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:P
  146. X``
  147. Xend
  148. Xsize 384
  149. END_OF_FILE
  150. if test 576 -ne `wc -c <'crabmask16.uu'`; then
  151.     echo shar: \"'crabmask16.uu'\" unpacked with wrong size!
  152. fi
  153. # end of 'crabmask16.uu'
  154. fi
  155. if test -f 'crabmask8' -a "${1}" != "-c" ; then 
  156.   echo shar: Will not clobber existing file \"'crabmask8'\"
  157. else
  158. echo shar: Extracting \"'crabmask8'\" \(111 characters\)
  159. sed "s/^X//" >'crabmask8' <<'END_OF_FILE'
  160. X..******..
  161. X.********.
  162. X**********
  163. X**********
  164. X**********
  165. X**********
  166. X**********
  167. X**********
  168. X.********.
  169. X..******..
  170. X
  171. END_OF_FILE
  172. if test 111 -ne `wc -c <'crabmask8'`; then
  173.     echo shar: \"'crabmask8'\" unpacked with wrong size!
  174. fi
  175. # end of 'crabmask8'
  176. fi
  177. if test -f 'crabs.c' -a "${1}" != "-c" ; then 
  178.   echo shar: Will not clobber existing file \"'crabs.c'\"
  179. else
  180. echo shar: Extracting \"'crabs.c'\" \(14330 characters\)
  181. sed "s/^X//" >'crabs.c' <<'END_OF_FILE'
  182. X/************************************************************************/
  183. X/*                                                                      */
  184. X/*                                   ######################             */
  185. X/*      A n t h o n y                      ##  ##  ##                   */
  186. X/*                                         ##########                   */
  187. X/*              T h y s s e n            ####  ##  ####                 */
  188. X/*                                     ####    ##    ####               */
  189. X/*                                   ####      ##      ####             */
  190. X/*                                                                      */
  191. X/************************************************************************/
  192. X
  193. X/*
  194. X**  Crabs - also for AMIGA under lattace C
  195. X*/
  196. X
  197. X#include <stdio.h>
  198. X#include <string.h>
  199. X#include <intuition/intuition.h>
  200. X#include <graphics/gfxmacros.h>
  201. X#include <exec/exec.h>
  202. X#include <proto/all.h>
  203. X#define BM_SRC 0xC0      /* minterm source only */
  204. X#define BM_DST 0xA0      /* minterm destination only */
  205. X
  206. X#include "crabs.h"
  207. X
  208. X /* intuition variables */
  209. Xstruct Library        *IntuitionBase = NULL, *GfxBase = NULL;
  210. Xstruct Screen         *WBScrn = NULL;
  211. Xstruct Window         *Window = NULL;        /* Window pointer */
  212. Xstruct RastPort       *RPwindow = NULL;      /* windows raster port */
  213. Xstruct Remember       *Remember = NULL;      /* memory allocation memory */
  214. Xstruct Task           *MyTask = NULL;        /* my tasks address */
  215. Xstruct IntuiMessage   *message = NULL;
  216. Xint                   WBScrX, WBScrY;        /* size of workbench screen */
  217. XULONG                 WindowSignal;          /* IDCMP window signal */
  218. Xstruct NewWindow      NW = {
  219. X        30, 200, 350, 40, 0, 1,               /* position, size and colors */
  220. X        CLOSEWINDOW,                         /* IDCMP messages */
  221. X        ACTIVATE| SIMPLE_REFRESH| WINDOWDEPTH|
  222. X           WINDOWDRAG| WINDOWCLOSE,          /* window flags */
  223. X        NULL, NULL,                          /* gadget, checkmark */
  224. X        (UBYTE *) " << CRABS >> ",           /* name of window */
  225. X        NULL,NULL,                           /* screen-> , BitMap-> */
  226. X        0,0,0,0,                             /* min and max size (disable) */
  227. X        WBENCHSCREEN                         /* screen type */
  228. X        };
  229. X
  230. X
  231. X   /* program varibles */
  232. Xtypedef struct {
  233. X  int             x, y;
  234. X}               point;
  235. X
  236. Xtypedef enum {
  237. X    Looking,          /* crab is looking for food */
  238. X    Nibbling,         /* crab took a nibble and is stepping back */
  239. X    Munching          /* crab is eating the food (after step back) */
  240. X} crabstatus;
  241. X
  242. Xstatic struct {
  243. X  crabstatus      stat;       /* current status of crab */
  244. X  point           pos;        /* upper left corner screen coords */
  245. X  point           vel;        /* velocity (pixels/cycle) */
  246. X  point           old;        /* last position for backward step */
  247. X  int             lp;         /* life points of this crab */
  248. X  struct RastPort *RP;        /* which map is the crab using */
  249. X}     crab[MAXCRABS];         /* crabs' state */
  250. X
  251. Xint     NumCrabs = 0;         /* number of crabs on screen */
  252. X
  253. X/* Crab images to be drawen to the screen using the mask */
  254. Xunsigned short chip   crabup[] =          /* facing up */
  255. X#  include "crabup.i"
  256. X#ifndef ONEIMAGE
  257. Xunsigned short chip   crabdown[] =        /* facing down */
  258. X#  include "crabdown.i"
  259. Xunsigned short chip   crabright[] =       /* facing right */
  260. X#  include "crabright.i"
  261. Xunsigned short chip   crableft[] =        /* facing left */
  262. X#  include "crableft.i"
  263. X#endif
  264. Xunsigned short chip   crabmask[] =        /* crabs mask */
  265. X#  include "crabmask.i"
  266. X
  267. X  /* Bitmaps and raster ports of the screens */
  268. Xstruct BitMap   BMtemp, BMmask, BMup;
  269. Xstruct RastPort RPtemp, RPmask, RPup, RPscreen;
  270. X#ifndef ONEIMAGE
  271. Xstruct BitMap   BMdown, BMright, BMleft;
  272. Xstruct RastPort RPdown, RPright, RPleft;
  273. X#endif
  274. X
  275. X
  276. X  /* function declarations */
  277. Xextern void     Init(), OpenLibraries(), InitWindow(), InitRP(), Print();
  278. Xextern void     CrabsExit(), Cycle(), DrawCrab(), HideCrab(), ModVel(), NewVel();
  279. Xextern BOOL     MoveCrab(), TestCrab(), TestBackground();
  280. Xextern void     RandInit();
  281. Xextern int      RandInt();
  282. X
  283. X#ifdef CBACK
  284. X  /* Cback.o initializations */
  285. XLONG _stack = 2000;
  286. Xchar *_procname = "Crabs";
  287. XLONG _priority = -1;
  288. XLONG _BackGroundIO = 0;
  289. X#endif
  290. X
  291. Xvoid
  292. X_main()
  293. X{
  294. X  Init();
  295. X
  296. X  for (;;) {
  297. X    Cycle();
  298. X  }
  299. X  /* NOTREACHED */
  300. X}
  301. X
  302. Xvoid
  303. XInit()
  304. X/* set up initial crab layer */
  305. X{
  306. X  int             i;           /* crab # */
  307. X
  308. X  OpenLibraries();        /* open the various system structures */
  309. X
  310. X  if( ! (Window = OpenWindow( &NW )) )
  311. X    CrabsExit(NULL);
  312. X  RPwindow = Window->RPort;
  313. X  WindowSignal = 1<<Window->UserPort->mp_SigBit;
  314. X
  315. X  InitWindow();
  316. X
  317. X  MyTask = FindTask( NULL );
  318. X  WBScrn = Window->WScreen;
  319. X  WBScrX = WBScrn->Width -SIZE;
  320. X  WBScrY = WBScrn->Height -SIZE/2;
  321. X
  322. X  memcpy((char *) &RPscreen, (char *) &(WBScrn->RastPort),
  323. X                                      sizeof( struct RastPort ));
  324. X
  325. X  InitRP(&RPup,    &BMup,    &crabup);
  326. X  InitRP(&RPmask,  &BMmask,  &crabmask);
  327. X  InitRP(&RPtemp,  &BMtemp,  NULL);
  328. X#ifndef ONEIMAGE
  329. X  InitRP(&RPdown,  &BMdown,  &crabdown);
  330. X  InitRP(&RPleft,  &BMdown,  &crableft);
  331. X  InitRP(&RPright, &BMright, &crabright);
  332. X#endif
  333. X
  334. X  RandInit();
  335. X
  336. X  /* Create initial set of crabs: */
  337. X  for (NumCrabs = 0; NumCrabs < STARTCRABS; NumCrabs++) {
  338. X    for (i = PLACELIM; i > 0; i--) {
  339. X      crab[NumCrabs].pos.x = RandInt(0, WBScrX-1);
  340. X      crab[NumCrabs].pos.y = RandInt(0, WBScrY-1);
  341. X      crab[NumCrabs].old = crab[NumCrabs].pos;
  342. X      if( !TestBackground(NumCrabs) )
  343. X        break;                              /* space found */
  344. X    }
  345. X    if( !i )                           /* did we reach the placement limit */
  346. X      CrabsExit("Can't place crabs! No empty space found!");
  347. X    crab[NumCrabs].lp = REPROlp / 2;
  348. X    crab[NumCrabs].stat = Looking;
  349. X    NewVel(NumCrabs);
  350. X    DrawCrab(NumCrabs);
  351. X  }
  352. X}
  353. X
  354. Xvoid
  355. XOpenLibraries()
  356. X{
  357. X  if( ! (IntuitionBase = OpenLibrary( "intuition.library", 0 )) )
  358. X    CrabsExit("Can't open Intuition Library");
  359. X  if( ! (GfxBase = OpenLibrary( "graphics.library", 0 )) )
  360. X    CrabsExit("Can't Open Graphics Library");
  361. X}
  362. X
  363. Xvoid
  364. XInitWindow()
  365. X{
  366. X  Move(RPwindow, Window->BorderLeft,
  367. X          Window->BorderTop + RPwindow->TxBaseline );
  368. X  SetAPen(RPwindow, 3);
  369. X  Print("Reproducing Crabs by Anthony Thyssen");
  370. X  SetAPen(RPwindow, 1);
  371. X  Print("   Original idea from Scientific American");
  372. X}
  373. X
  374. Xvoid
  375. XInitRP(rp, bm, image)
  376. X  struct RastPort *rp;
  377. X  struct BitMap   *bm;
  378. X  short           *image;
  379. X{
  380. X  InitBitMap(bm,  1, SIZE,SIZE/2);
  381. X  if( image )
  382. X    bm->Planes[0] = (PLANEPTR) image;
  383. X  else
  384. X    if( !(bm->Planes[0] = (PLANEPTR)
  385. X         AllocRemember( &Remember, RASSIZE(SIZE,SIZE/2),
  386. X             MEMF_CHIP | MEMF_CLEAR) ) ) {    /* allocate with memory */
  387. X      CrabsExit("Can't alloc raster");
  388. X    }
  389. X  InitRastPort( rp );
  390. X  rp->BitMap = bm;
  391. X}
  392. X
  393. Xvoid
  394. XPrint(str)
  395. X  char *str;
  396. X{
  397. X  Text( RPwindow, str, strlen(str) );
  398. X  Move( RPwindow, Window->BorderLeft,
  399. X      RPwindow->cp_y + RPwindow->TxHeight); /* move to next line */
  400. X}
  401. X
  402. Xvoid
  403. XCrabsExit(exitmessage)
  404. X  char *exitmessage;
  405. X/* exit crabs - remove all traces */
  406. X{
  407. X  int             i;
  408. X
  409. X  for (i = 0; i < NumCrabs; ++i)
  410. X    HideCrab(i);
  411. X
  412. X  RefreshWindowFrame(Window);
  413. X  InitWindow();
  414. X  if( Window && exitmessage ) {
  415. X    Print(exitmessage);
  416. X    /*printf("%s\n", exitmessage); /* Debugging */
  417. X    Delay(200);
  418. X  }
  419. X
  420. X  FreeRemember( &Remember, TRUE );    /* Frre all allocated memory */
  421. X
  422. X  if( Window )          CloseWindow( Window );
  423. X  if( GfxBase )         CloseLibrary( GfxBase );
  424. X  if( IntuitionBase )   CloseLibrary( IntuitionBase );
  425. X
  426. X  _exit(0);
  427. X}
  428. X
  429. Xvoid
  430. XCycle()
  431. X  /* one motion cycle for all crabs */
  432. X{
  433. X  int             i;
  434. X
  435. X  /* test for window closure */
  436. X  if( message = (struct IntuiMessage *)GetMsg(Window->UserPort) ) {
  437. X    ReplyMsg( (struct Message *)message );
  438. X    switch( message->Class ) {
  439. X      case CLOSEWINDOW : /* window closed message */
  440. X        CrabsExit("Crabs are Exiting");
  441. X    }
  442. X  } /* Message test */
  443. X
  444. X  if( NumCrabs < 5 )
  445. X    Delay( DELAY );         /* slow down the small number of crabs */
  446. X
  447. X  for (i = 0; i < NumCrabs; i++) {
  448. X
  449. X    /* did something bite the crab - image corrupted ? */
  450. X    if (TestCrab(i)) {              /* if so damage the crab */
  451. X      crab[i].lp -= BITElp;
  452. X      NewVel(i);
  453. X    }
  454. X
  455. X    switch( crab[i].stat ) {        /* do the nessary move */
  456. X      case Looking:
  457. X        HideCrab(i);                 /* erase crab from previous position */
  458. X        crab[i].old = crab[i].pos;   /* record current position */
  459. X        if (MoveCrab(i))             /* find the new positioN */
  460. X          crab[i].lp -= BOUNCElp;    /* crab bounced - that smarts */
  461. X        if (TestBackground(i))       /* Test if crab hits an object */
  462. X          crab[i].stat = Nibbling;   /* if so crab will now nibble */
  463. X        crab[i].lp -= MOVElp;        /* drain movement cost from crab */
  464. X        if (crab[i].lp < 0) {        /* check on starvation */
  465. X          crab[i] = crab[--NumCrabs];
  466. X          if (NumCrabs == 0)
  467. X            CrabsExit("The last Crab just died!\n");
  468. X          i--;
  469. X          continue;                  /* repeat this crab as it is the next one */
  470. X        }
  471. X        DrawCrab(i);                 /* redraw crab here */
  472. X        ModVel(i, 1);                /* very slight direction change */
  473. X        break;
  474. X
  475. X      case Nibbling:
  476. X        HideCrab(i);                 /* erase crab from previous position */
  477. X        crab[i].pos = crab[i].old;   /* move crab backwards */
  478. X        DrawCrab(i);                 /* draw crab here */
  479. X        crab[i].stat = Munching;     /* chew over the food */
  480. X        break;
  481. X
  482. X      case Munching:
  483. X        crab[i].lp += FEEDlp;        /* feed the food to the crab */
  484. X        ModVel(i, FEEDVEL);          /* look in roughly the same dir as before */
  485. X        crab[i].stat = Looking;      /* time taken to eat - look for more */
  486. X        if (crab[i].lp >= REPROlp) { /* check for reproduction */
  487. X          HideCrab(i);               /* remove parent */
  488. X          crab[i].lp /= 2;           /* half life force */
  489. X          if (NumCrabs < MAXCRABS) { /* is a new crab is possible */
  490. X            crab[NumCrabs] = crab[i]; /* child is a copy of parent */
  491. X            crab[NumCrabs].vel.x = -crab[NumCrabs].vel.x; /* reverse dir */
  492. X            crab[NumCrabs].vel.y = -crab[NumCrabs].vel.y;
  493. X            crab[NumCrabs].lp -= BITElp; /* child is weak */
  494. X            MoveCrab(i);             /* move crabs away from each other */
  495. X            MoveCrab(NumCrabs++);    /* move child twice - inc number crabs */
  496. X            /* leave the child undrawen and corrupted! */
  497. X          }
  498. X          DrawCrab(i);               /* draw parent regardless of child state */
  499. X        }
  500. X        break;
  501. X    }
  502. X  }                                 /* move next crab */
  503. X}
  504. X
  505. XBOOL
  506. XMoveCrab(i)
  507. X  int             i;
  508. X/* move crab to on screen position - don't draw it */
  509. X/* if the crab hits edge of screen return TRUE */
  510. X{
  511. X  BOOL        hit = FALSE;
  512. X
  513. X  crab[i].pos.x += crab[i].vel.x;        /* motion */
  514. X  crab[i].pos.y += crab[i].vel.y;
  515. X  if( crab[i].pos.x < 0 ) {
  516. X    crab[i].pos.x = 0;
  517. X    crab[i].vel.x = abs(crab[i].vel.x);
  518. X    hit = TRUE;
  519. X  }
  520. X  if( crab[i].pos.x > WBScrX ) {
  521. X    crab[i].pos.x = WBScrX;
  522. X    crab[i].vel.x = -abs(crab[i].vel.x);
  523. X    hit = TRUE;
  524. X  }
  525. X  if( crab[i].pos.y < 0 ) {
  526. X    crab[i].pos.y = 0;
  527. X    crab[i].vel.y = abs(crab[i].vel.y);
  528. X    hit = TRUE;
  529. X  }
  530. X  if( crab[i].pos.y > WBScrY ) {
  531. X    crab[i].pos.y = WBScrY;
  532. X    crab[i].vel.y = -abs(crab[i].vel.y);
  533. X    hit = TRUE;
  534. X  }
  535. X  return (hit);
  536. X}
  537. X
  538. XBOOL
  539. XTestCrab(i)
  540. X  int             i;
  541. X/* test the crabs image on the screen. return TRUE if corrupt */
  542. X/* invisible crabs are the background texture */
  543. X{
  544. X  int j;
  545. X  UBYTE *byte;
  546. X
  547. X  /* get crab stored on screen */
  548. X  ClipBlit( &RPscreen, crab[i].pos.x, crab[i].pos.y,
  549. X            &RPtemp, 0, 0, SIZE, SIZE/2, BM_SRC );
  550. X  /* mask out background */
  551. X  ClipBlit( &RPmask, 0, 0, &RPtemp, 0, 0,
  552. X            SIZE, SIZE/2, BM_SRC & BM_DST );
  553. X  /* xor with crab image */
  554. X  ClipBlit( crab[i].RP, 0, 0, &RPtemp, 0, 0,
  555. X            SIZE, SIZE/2, BM_SRC ^ BM_DST );
  556. X
  557. X  /* check the data */
  558. X  byte = BMtemp.Planes[0];
  559. X  for (j = RASSIZE(SIZE, SIZE/2)-1; j >= 0; j--)
  560. X    if( *(byte++) )
  561. X      return TRUE;
  562. X
  563. X  return FALSE;
  564. X}
  565. X
  566. XBOOL
  567. XTestBackground(i)
  568. X  int             i;
  569. X/* return TRUE if crab position is not the background */
  570. X{
  571. X  int  j;
  572. X  UBYTE *byte;
  573. X
  574. X  /* get screen at crab location */
  575. X  ClipBlit( &RPscreen, crab[i].pos.x, crab[i].pos.y,
  576. X            &RPtemp, 0, 0, SIZE, SIZE/2, BM_SRC );
  577. X  /* mask out background */
  578. X  ClipBlit( &RPmask, 0, 0, &RPtemp, 0, 0,
  579. X            SIZE, SIZE/2, BM_SRC & BM_DST );
  580. X
  581. X  /* check the data */
  582. X  byte = BMtemp.Planes[0];
  583. X  for (j = RASSIZE(SIZE, SIZE/2)-1; j >= 0; j--)
  584. X    if( *(byte++) )
  585. X      return TRUE;
  586. X
  587. X  return FALSE;
  588. X}
  589. X
  590. Xvoid
  591. XHideCrab(i)
  592. X/* over write current crab with screen texture */
  593. X{
  594. X  ClipBlit( &RPmask, 0, 0, &RPscreen, crab[i].pos.x, crab[i].pos.y,
  595. X            SIZE, SIZE/2, ~BM_SRC & BM_DST );
  596. X}
  597. X
  598. Xvoid
  599. XDrawCrab(i)
  600. X  int             i;
  601. X/* Draw the crabs on the screen if visible */
  602. X{
  603. X  HideCrab(i);
  604. X  crab[i].RP = PICKMAP( crab[i].vel );
  605. X  ClipBlit( crab[i].RP, 0, 0, &RPscreen, crab[i].pos.x, crab[i].pos.y,
  606. X            SIZE, SIZE/2, BM_SRC | BM_DST );
  607. X}
  608. X
  609. Xvoid
  610. XNewVel(i)                              /* assign new velocity to crab */
  611. X  int             i;                   /* crab # */
  612. X{
  613. X  crab[i].vel.x = RandInt(-MAXVEL, MAXVEL);
  614. X  crab[i].vel.y = RandInt(-MAXVEL/2, MAXVEL/2);
  615. X
  616. X  /* Velocity (0,0) is okay since we repeatedly modify all velocities. */
  617. X}
  618. X
  619. Xvoid
  620. XModVel(i, dv)                              /* randomly modify crab velocity */
  621. X  int             i,dv;                   /* crab, delta velocity */
  622. X{
  623. X  int             min,max;                 /* range of new velocity */
  624. X
  625. X  min=crab[i].vel.x-dv;
  626. X  max=crab[i].vel.x+dv;
  627. X  if ( max > MAXVEL)
  628. X    max = MAXVEL;
  629. X  if ( min < -MAXVEL)
  630. X    min = -MAXVEL;
  631. X  crab[i].vel.x = RandInt(min, max);
  632. X
  633. X  min=crab[i].vel.y-dv;
  634. X  max=crab[i].vel.y+dv;
  635. X  if ( max > MAXVEL/2)
  636. X    max = MAXVEL/2;
  637. X  if ( min < -MAXVEL/2)
  638. X    min = -MAXVEL/2;
  639. X  crab[i].vel.y = RandInt(min, max);
  640. X}
  641. X
  642. Xvoid
  643. XRandInit()
  644. X{
  645. X  srand((int)time(NULL));
  646. X}
  647. X
  648. Xint
  649. XRandInt(lo, hi)                        /* generate random integer in range */
  650. X  int             lo, hi;              /* range lo..hi inclusive */
  651. X{
  652. X  return lo + (int)( (unsigned)rand() % (hi - lo +1) );
  653. X}
  654. X
  655. X
  656. END_OF_FILE
  657. if test 14330 -ne `wc -c <'crabs.c'`; then
  658.     echo shar: \"'crabs.c'\" unpacked with wrong size!
  659. fi
  660. # end of 'crabs.c'
  661. fi
  662. if test -f 'crabs.h' -a "${1}" != "-c" ; then 
  663.   echo shar: Will not clobber existing file \"'crabs.h'\"
  664. else
  665. echo shar: Extracting \"'crabs.h'\" \(1513 characters\)
  666. sed "s/^X//" >'crabs.h' <<'END_OF_FILE'
  667. X/* The Crabs header file */
  668. X
  669. X#define    STARTCRABS  1               /* default start number of crabs */
  670. X#define    MAXCRABS    40              /* max number of crabs */
  671. X#define    SIZE        12             /* X size of the bitmaps,half for Y */
  672. X#define    ONEIMAGE                    /* movement style */
  673. X
  674. X#define    MAXVEL      8               /* abs. bound on velocity component */
  675. X#define    FEEDVEL     2               /* velocity change after a feed */
  676. X#define    DELAY       3               /* sleep time bettween cycles */
  677. X#define    PLACELIM    50              /* times to try to find a blank spot */
  678. X
  679. X
  680. X#define    FEEDlp      12              /* number of life points in one feed */
  681. X#define    BITElp      30              /* damage from being eaten */
  682. X#define    MOVElp      1               /* life points for a move */
  683. X#define    BOUNCElp    0               /* hiting the screen edge hurts */
  684. X#define    REPROlp     400             /* life points to reproduce at */
  685. X
  686. X/* movement style */
  687. X#ifdef SIDEWAYS
  688. X#  define PICKMAP(v)  ( abs((v).x) > abs((v).y * 2 ) ? \
  689. X                           ( (v).y > 0 ? &RPdown : &RPup ) : \
  690. X                           ( (v).x > 0 ? &RPright : &RPleft ) )
  691. X#endif
  692. X
  693. X#ifdef FORWARD
  694. X#  define PICKMAP(v)  ( abs((v).x) > abs((v).y * 2 ) ? \
  695. X                           ( (v).x > 0 ? &RPright : &RPleft ) : \
  696. X                           ( (v).y > 0 ? &RPdown : &RPup ) )
  697. X#endif
  698. X
  699. X#ifdef ONEIMAGE         /* only the crabup.i image is used */
  700. X#  define PICKMAP(v)  ( &RPup )
  701. X#endif
  702. END_OF_FILE
  703. if test 1513 -ne `wc -c <'crabs.h'`; then
  704.     echo shar: \"'crabs.h'\" unpacked with wrong size!
  705. fi
  706. # end of 'crabs.h'
  707. fi
  708. if test -f 'crabs.info.uu' -a "${1}" != "-c" ; then 
  709.   echo shar: Will not clobber existing file \"'crabs.info.uu'\"
  710. else
  711. echo shar: Extracting \"'crabs.info.uu'\" \(387 characters\)
  712. sed "s/^X//" >'crabs.info.uu' <<'END_OF_FILE'
  713. Xbegin 644 crabs.info
  714. XMXQ```0```````````"(`#``$``,``0#`J#``````````````````````````"
  715. XM`````\(`P&Z(`,"H2(````"````````````````````````````B``L``@##=
  716. XM-;@#``````````__P```0`(/P``"```!P```$`#PP``$``/\P```("#PP```%
  717. XM@0``P```"``/P``"``?_P`````?_P``(``?_P```````````````````````T
  718. XM`````````````````````````````````````````````````````````````
  719. X8```````````!``````P````!``````$`/
  720. X``
  721. Xend
  722. Xsize 249
  723. END_OF_FILE
  724. if test 387 -ne `wc -c <'crabs.info.uu'`; then
  725.     echo shar: \"'crabs.info.uu'\" unpacked with wrong size!
  726. fi
  727. # end of 'crabs.info.uu'
  728. fi
  729. if test -f 'crabs.uu' -a "${1}" != "-c" ; then 
  730.   echo shar: Will not clobber existing file \"'crabs.uu'\"
  731. else
  732. echo shar: Extracting \"'crabs.uu'\" \(7341 characters\)
  733. sed "s/^X//" >'crabs.uu' <<'END_OF_FILE'
  734. Xbegin 644 crabs
  735. XM```#\P`````````$``````````,```2(0```!@````````+"```#Z0``!(@DO
  736. XM2"0`2?D`````1_D```&<<@`@/````EM@`B;!4<C__"QX``0I3@'4*4\!W$*L*
  737. XM`=@F;@$4<``B/```,`!.KO[.*6L`F`'02JL`K&<``'`@#Y"O``0&@````(`I>
  738. XM0`&@80`!+B!K`*S1R-'((F@`$-/)T\D@`G(`$ADI20'DT(%2@$)G4H`"0/_^?
  739. XMG\!5@$)W"``@`E.`U($?L@``(`!3@E'(__8?O``@(`!3@A^Q(``@`%'*__@B'
  740. XM3R\)8```>"EK`#H!H'!_4H#1K`&@80``PD'K`%Q.KOZ`0>L`7$ZN_HPI0`'8B
  741. XM+P`D0"`J`"1G$BQL"O@@0"(H```I00'03J[_@B(J`"!G&B0\```#[4ZN_^(IY
  742. XM0`'@9PKEB"!`)V@`"`"D(&P!V"\(2&P!G"!H`"0I:``$`>1.N@N83KH`='``$
  743. XM8`0@+P`$+P`@+`'(9P0@0$Z03KH0<"QX``0B;`KX3J[^8DZZ"VY*K`'89QHBS
  744. XM+`'@9P1.KO_<+'@`!$ZN_WPB;`'83J[^AB`?+FP!W$YU<&1@M$/Z`!!P`$ZNO
  745. XM_=@I0`KX9^Q.=61O<RYL:6)R87)Y`&$```AA``.T8/I.5?_\2.<!(F$``:I!7
  746. XM[``N+&P``$ZN_S0I0``,2H!F"$*G80`"]%A/(&P`#"EH`#(`$")H`%9P`!`II
  747. XM``]R`>&A*4$!\&$``;23R2QX``1.KO[:*4``&"!L``PI:``N``@@;``(,"@`9
  748. XM#$C`<@R0@2E``>@P*``.2,!=@"E``>Q#Z`!4<&-![`DX$-E1R/_\2'D`````4
  749. XM2&P'Y$AL"-1A``&Z2'D````,2&P'O$AL"'!A``&H0I=(;`>42&P(#&$``9IA2
  750. XM``H@3^\`($*L`%X,K`````$`7FP``-9^,DJ';P``B"`L`%YR)$ZZ#8XB+`'H_
  751. XM4X$O`4*G+T``%&$`"?A![`'T(B\`%"&`&`0@+`!><B1.N@UF(BP![%.!+H%"1
  752. XMIR]``!AA``G00>P!]"(O`!@A@!@(("P`7G(D3KH-/D'L`?0B2-/`T<!%Z0`4Y
  753. XM0^@`!"39)-DNK`!>80`'6$_O``Q*0&<&4X=@`/]V2H=F"DAL`&)A``&H6$\@Y
  754. XM+`!><B1.N@SZ0>P!]"&\````R`@<0>P!]$*P"``O+`!>80`(1"ZL`%YA``?D?
  755. XM6$]2K`!>8`#_(DS?1(!.74YU+PY#[`",<``L>``$3J[]V"E```!*@&8*2&P`9
  756. XMGF$``4983T/L`+QP`"QX``1.KOW8*4``!$J`9@I(;`#.80`!)EA/+%].=4CG6
  757. XM(`(@;``,$"@`-DB`2,`2*``W2(%(P70`(&P`$#0H`#[2@B)(+&P`!$ZN_Q`BL
  758. XM;``0<`-.KOZJ2&P`ZF$``(@B;``0<`$L;``$3J[^JDAL`1!A``!R4$],WT`$/
  759. XM3G5.50``2.<@,B9O`!@D;P`<($IP`7(,=`8L;``$3J[^>DJM`!!G""5M`!``^
  760. XM"&`D0>P`%'`,(CP``0`"+&P``$ZN_G0E0``(9@I(;`$Z80``<EA/(DLL;``$_
  761. XM3J[_.B=*``1,WTP$3EU.=4Y5__Q(YR`2)F\`&"!+2AAF_%.(D<LO2``,(FP`V
  762. XM$"!+("\`#"QL``1.KO_$(&P`#!`H`#9(@$C`(&P`$#(H`"9(P70`-"@`.M*"*
  763. XM(DA.KO\03-](!$Y=3G5(YP$2)F\`$'X`OJP`7FP,+P=A``846$]2AV#N(&P`*
  764. XM#"QL``!.KOXX80#^N$JL``QG&"`+9Q0O"V$`_VY83W)DTH$L;`KX3J[_.D'LH
  765. XM`!1P`2QL``!.KOYH2JP`#&<((&P`#$ZN_[A*K``$9PPB;``$+'@`!$ZN_F)*(
  766. XMK```9PPB;```+'@`!$ZN_F)"ITZZ#`183TS?2(!.=4Y5__Q(YR$R(&P`#"!H/
  767. XM`%8L>``$3J[^C"E``!Q*@&<@(D!.KOZ&(&P`'"`H`!0,@````@!F"DAL`4YAB
  768. XM`/\L6$\,K`````4`7FP*<@,L;`KX3J[_.GX`OJP`7FP``C8O!V$``]A83TI`T
  769. XM9QH@!W(D3KH*5G(>0^P!]).Q"!PO!V$`!:Q83R`'<B1.N@H\0>P!]"(P"``,$
  770. XM@0````)G``$4#($````!9P``R$J!9@`!X"\'80`$WB`'<B1.N@H,0^P!]"1)S
  771. XMU<#3P$?J`!1%Z0`$)MHFVBZ'80`!Q%A/2D!G""`'<B1.N@GB+P=A``046$]*J
  772. XM0&<2(`=R)$ZZ"<YR`4'L`?0A@0@`(`=R)$ZZ";Q![`'T4[`('$'L`?0B,`@<_
  773. XM2H%J-D'L`?0B2-/`4ZP`7B`L`%YR)$ZZ"9+1P'`((MA1R/_\2JP`7F8*2&P!:
  774. XM8&$`_AQ83U.'8``!."\'80`$>DAX``$O!V$`!2)/[P`,8``!("\'80`$'B`'T
  775. XM<B1.N@E,0^P!]"1)U<#3P$?J``1%Z0`4)MHFVBZ'80`$/EA/(`=R)$ZZ"29R(
  776. XM`D'L`?0A@0@`8```WB`'<B1.N@D0<@Q#[`'TT[$('$AX``(O!V$`!+Q03R`'3
  777. XM<B1.N@CR0>P!]$*P"`!![`'T#+````&0"!QM``"@+P=A``.>6$\@!W(D3KH(`
  778. XMRD'L`?0B,`@<:@)2@>*!0>P!]"&!"!PO0``4(BP`7G0HLH)L8G`D3KH(H$'LJ
  779. XM`?0B2-/`(B\`%"1(U<%R""+:4<G__$/L`?0B,0@,1(%#[`'T(X$(#$/L`?0B6
  780. XM,0@01(%#[`'T(X$($'(>0>P!]).P"!PO!V$``"@@+`!>4JP`7BZ`80``&EA/<
  781. XM+P=A``-,6$]2AV``_<9,WTR$3EU.=4Y5__A(YR,`+B\`''P`(`=R)$ZZ"!A!Y
  782. XM[`'T(C`(#$/L`?33L0@$0>P!]"(P"!!#[`'TT[$("$'L`?0B,`@$2H%J1'(`J
  783. XM0>P!]"&!"`0O0``00>P!]"0P"`Q*@FH,0>P!]"0P"`Q$@F`0(`=R)$ZZ![Y!F
  784. XM[`'T)#`(#$'L`?0@+P`0(8((#'P!(`=R)$ZZ!Z`B+`'H0>P!]"0P"`2T@6]$+
  785. XM0>P!]"&!"`0O0``00>P!]"(P"`Q*@6H,0>P!]"(P"`Q$@6`0(`=R)$ZZ!V1!&
  786. XM[`'T(C`(#$2!0>P!]"`O`!`A@0@,?`$@!W(D3KH'1$'L`?0B,`@(2H%J1'(`_
  787. XM0>P!]"&!"`@O0``00>P!]"0P"!!*@FH,0>P!]"0P"!!$@F`0(`=R)$ZZ!PI!^
  788. XM[`'T)#`($$'L`?0@+P`0(8(($'P!(`=R)$ZZ!NPB+`'L0>P!]"0P"`BT@6]$F
  789. XM0>P!]"&!"`@O0``00>P!]"(P"!!*@6H,0>P!]"(P"!!$@6`0(`=R)$ZZ!K!!=
  790. XM[`'T(C`($$2!0>P!]"`O`!`A@0@0?`$@!DS?`,1.74YU3E7_^$CG`P`N+P`8,
  791. XM(`=R)$ZZ!GI(>`#`2'@`!DAX``QR`"\!+P%(;`@,0>P!]"\P"`A![`'T+S`(+
  792. XM!$AL"3A.N@@02'@`@$AX``9(>``,<``O`"\`2&P(#"\`+P!(;`AP3KH'[D_O&
  793. XM`$@@!W(D3KH&'DAX`&!(>``&2'@`#'(`+P$O`4AL"`PO`2\!0>P!]"\P""!.4
  794. XMN@>\3^\`)"ML!YS_^'P+2H9K%"!M__A2K?_X2A!G!'`!8`93AF#H<`!,WP#`X
  795. XM3EU.=4Y5__A(YP,`+B\`&"`'<B1.N@6V2'@`P$AX``9(>``,<@`O`2\!2&P(/
  796. XM#$'L`?0O,`@(0>P!]"\P"`1(;`DX3KH'3$AX`(!(>``&2'@`#'``+P`O`$AL.
  797. XM"`PO`"\`2&P(<$ZZ!RI/[P!(*VP'G/_X?`M*AFL4(&W_^%*M__A*$&<$<`%@T
  798. XM!E.&8.AP`$S?`,!.74YU+P<N+P`((`=R)$ZZ!2I(>``@2'@`!DAX``Q![`'T3
  799. XM+S`("$'L`?0O,`@$2&P).'(`+P$O`4AL"'!.N@;`3^\`)"X?3G4O!RXO``@OY
  800. XM!V&R(`=R)$ZZ!.)![`C40^P!]".(""!(>`#@2'@`!DAX``Q![`'T+S`("$'LU
  801. XM`?0O,`@$2&P).'(`+P$O`4'L`?0O,`@@3KH&:$_O`"@N'TYU3E7__"\'+B\`M
  802. XM$"`'<B1.N@2*2'@`"$AX__@O0``,80``]D'L`?0B+P`,(8`8#"`'<B1.N@1FG
  803. XM2'@`!$AX__PO0``480``TD'L`?0B+P`4(8`8$"XM__A.74YU3E7__$CG#P`N/
  804. XM+P`<+"\`("`'<B1.N@0J0>P!]"(P"`R2ABH!0>P!]"(P"`S2AB@!<@BX@6\"Q
  805. XM*`%R^+J!;`(J`2\$+P4O0``880``<E!/0>P!]"(O`!`A@!@,(`=R)$ZZ`^!!X
  806. XM[`'T(C`($)*&*@%![`'T(C`($-*&*`%R!+B!;P(H`7+\NH%L`BH!+P0O!2]`\
  807. XM`!AA```H0>P!]"(O`!@A@!@03.T`\/_L3EU.=4*G3KH`["Z`3KH"*EA/3G5(H
  808. XMYP,`+B\`#"PO`!!.N@'Z(@:2AU*!3KH#OB`'T(%,WP#`3G5.=4YU3E7_^"\+>
  809. XM)FP*W"`+9@1'^@!\&5,*\!EK``$*\1EK``(*\D(L"O-![`KP*4@*Z$'K``-(>
  810. XM;?_X+PA.N@%:4$]6@-?`("W_^"(\```.$$ZZ`PXI0`KD2A-G'AE3"O09:P`!+
  811. XM"O49:P`""O9P`!E`"O=R`2E!"N!@"$(L"O1"K`K@0>P*]"E("NPF7TY=3G5#*
  812. XM4U0V`````````````````````````````````````````````````````$Y5`
  813. XM__)(YP<0)F\`)DAM__A.N@%"6$]Z`!`M__DL``8&``I^`+X&9")P`!`'5(!R6
  814. XM!$ZZ`I)*@68(!H4```%N8`8&A0```6U2!V#:?@$0+?_ZO@!D%'``$`=R`$'L6
  815. XM`7\2,`@`VH%2!V#D<``0!E2`<@1.N@)22H%F#!`M__IR`K`!8P)2A7``$"W_N
  816. XM^U.`VH`@!7(83KH"$"H`<``0+?_\VH`@!7(\3KH!_BH`<``0+?_]VH`@!7(\W
  817. XM3KH!["H`<``0+?_^VH!.NOZ"VJP*Y"`+9P(FA2`%3-\(X$Y=3G4@;P`$(DARS
  818. XM`'``+P(,$``K9P8,$``M9@)22!`8!```,&T2#```"6X,)`'E@=*"TH'2@&#F4
  819. XM#!$`+68"1($D'R`(4X`@;P`(((&0B4YU("P!C"(\```.74ZZ`7!6@`*`?___Y
  820. XM_RE``8Q.=2\'+B\`""E'`8PN'TYU``!.5?_@2.<O$"9O`$!![?_T(@@L;`KX*
  821. XM3J[_0"`M__0N/```![HL`"M`__`,A@```6UO'B`'<@1.N@$X2H%F"`2&```!;
  822. XM;F`&!(8```%M4H=@V@R&```!;680(`=R!$ZZ`1)*@6<$4H=\`"`&(@<$@0``L
  823. XM![P700`!=``4`2M`__`@`G($3KH`[$J!9@1P'6`"<!P90`&1>``J+?_P<`RX8
  824. XM@&P><`!![`&0$#!(`+"%;A!P`$'L`9`0,$@`FH!2A&#<(`4B!%*!%T$``BM`X
  825. XM__!2@!=```,@+?_T<@=.N@"6%H$@+?_X<CQ.N@"*%T``!"`M__AR/$ZZ`'P7U
  826. XM00`%("W__'(R3KH`;A=```8@+?_\<C).N@!@TH$700`'3-\(]$Y=3G4`````@
  827. XM``!P82\'+B\`"$JL`<QG!$ZZ`/XB!RQL"OA.KO_<<``N'TYU````````<&%(3
  828. XMYS``)``F`4A"2$/$P<;`P,'40TA"0D+0@DS?``Q.=4J`:@``'D2`2H%J```,+
  829. XM1(%A```@1(%.=6$``!A$@$2!3G5*@6H```Q$@6$```9$@$YU+P)(030!9@``<
  830. XM(DA`2$%(0C0`9P``!H3!,`)(0#0`A,$P`DA",@(D'TYU+P-V$`Q!`(!D```&[
  831. XMX9E10PQ!"`!D```&Z9E90PQ!(`!D```&Y9E50TI!:P``!N.94T,T`.:H2$)"T
  832. XM0N:J2$.`P38`,`(T`TA!Q,&0@F0```A30]"!9/YR`#(#2$/GN$A`P4$F'R0?U
  833. XM3G5(YP$"<``B/```,``L>``$3J[^SBX``H<``#``2H=F!'``8"!*K`',9Q@@7
  834. XM;`',3I!*@&8$<`!@#$AX`!1.N@`26$\@!TS?0(!.=6&T3G4``$CG!P`N+P`0,
  835. XM("P!?%.`+`!*1FLP(`9(P.>`0>P)G"HP"`!*!6<:"`4``F84(`9(P.>`0>P)@
  836. XMG"\P"`1.NOYH6$]31F#,+P=.NN^66$],WP#@3G4``````````````````$CG(
  837. XM`#(F;`K\(`MG%"13(DL@*P`(+'@`!$ZN_RXF2F#HD<@I2`L`*4@*_$S?3`!.!
  838. XM=4CG/@(L;``$(&\`'$SO``,`(")O`"A,[P!\`"Q.KOW83-]`?$YU````````@
  839. XM``!P80```^P````"`````0```E@```)&`````@````,````,````!@``````\
  840. XM``/R0``#Z@````8```\`/\`_P`\````?@'_@__#_\'_@'X````/R```#Z0``_
  841. XM``````/R```#Z@```&<`````````````````````````````````````````)
  842. XM`"`\/"!#4D%"4R`^/B```!X`R`%>`"@``0```@```!!.```````````````@-
  843. XM```````````````````````!`````$-A;B=T('!L86-E(&-R86)S(2!.;R!E!
  844. XM;7!T>2!S<&%C92!F;W5N9"$``&EN='5I=&EO;BYL:6)R87)Y`$-A;B=T(&]P%
  845. XM96X@26YT=6ET:6]N($QI8G)A<GD``&=R87!H:6-S+FQI8G)A<GD``$-A;B=T,
  846. XM($]P96X@1W)A<&AI8W,@3&EB<F%R>0!297!R;V1U8VEN9R!#<F%B<R!B>2!!A
  847. XM;G1H;VYY(%1H>7-S96X``"`@($]R:6=I;F%L(&ED96$@9G)O;2!38VEE;G1IY
  848. XM9FEC($%M97)I8V%N`$-A;B=T(&%L;&]C(')A<W1E<@``0W)A8G,@87)E($5X;
  849. XM:71I;F<`5&AE(&QA<W0@0W)A8B!J=7-T(&1I960A"@```````"@?'!\>'QX?K
  850. XM'QX?'A\````!'QP?'A\>'Q\>'QX?```#[`````$````#````2`````````/RW
  851. X``
  852. Xend
  853. Xsize 5220
  854. END_OF_FILE
  855. if test 7341 -ne `wc -c <'crabs.uu'`; then
  856.     echo shar: \"'crabs.uu'\" unpacked with wrong size!
  857. fi
  858. # end of 'crabs.uu'
  859. fi
  860. if test -f 'intergerize.c' -a "${1}" != "-c" ; then 
  861.   echo shar: Will not clobber existing file \"'intergerize.c'\"
  862. else
  863. echo shar: Extracting \"'intergerize.c'\" \(963 characters\)
  864. sed "s/^X//" >'intergerize.c' <<'END_OF_FILE'
  865. X/*
  866. X** This program filters a small file such that the output
  867. X** is the set of short ints required to describe the input
  868. X**  NOTE the file must be a rectangle to work and no tabs
  869. X*/
  870. X
  871. X#include <stdio.h>
  872. X
  873. Xchar            file[100][100];
  874. Xint             linelen, numlines;
  875. X
  876. Xmain()
  877. X{
  878. X  int             i;
  879. X
  880. X  linelen = 0;
  881. X  numlines = 0;
  882. X  while (gets(&file[numlines][0]) != NULL && numlines < 99) {
  883. X    if ((i = strlen(&file[numlines][0])) > linelen)
  884. X      linelen = i;
  885. X    numlines++;
  886. X  }
  887. X  for(i=0; i<numlines; i++) {
  888. X    printf("%s0x%c%c%c%c",
  889. X       !i ? "{ " : i%8 != 7 ? ", " : ",\n  ",
  890. X       conv(i,0), conv(i,4), conv(i,8), conv(i,12) );
  891. X  }
  892. X  printf("  };\n");
  893. X  return 0;
  894. X}
  895. X
  896. Xconv(line, pos)
  897. X{
  898. X  int             i;
  899. X  static char     hex[] = "0123456789abcdef";
  900. X
  901. X  i = (file[line][pos] == '*') ? 8 : 0;
  902. X  i += (file[line][pos + 1] == '*') ? 4 : 0;
  903. X  i += (file[line][pos + 2] == '*') ? 2 : 0;
  904. X  i += (file[line][pos + 3] == '*') ? 1 : 0;
  905. X  return (hex[i]);
  906. X}
  907. END_OF_FILE
  908. if test 963 -ne `wc -c <'intergerize.c'`; then
  909.     echo shar: \"'intergerize.c'\" unpacked with wrong size!
  910. fi
  911. # end of 'intergerize.c'
  912. fi
  913. if test -f 'makefile' -a "${1}" != "-c" ; then 
  914.   echo shar: Will not clobber existing file \"'makefile'\"
  915. else
  916. echo shar: Extracting \"'makefile'\" \(504 characters\)
  917. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  918. X
  919. Xcrabs : crabs.c crabs.h crabup.i crabmask.i
  920. X        lc -v -Lc $@
  921. X
  922. Xcrabup.i : blob intergerize rotate
  923. X        intergerize <$* >$@
  924. X        copy crabup.i crabdown.i
  925. X        copy crabup.i crableft.i
  926. X        copy crabup.i crabright.i
  927. X
  928. Xcrabmask.i : blobmask intergerize
  929. X        intergerize <$* >$@
  930. X
  931. Xintergerize : intergerize.c
  932. X        lc -L $@
  933. X
  934. Xrotate : rotate.c
  935. X        lc -L $@
  936. X
  937. Xmerge : merge.c
  938. X        lc -L $@
  939. X
  940. Xclean :
  941. X        delete *.o *.lnk *.i
  942. X
  943. Xclobber : clean
  944. X        delete intergerize rotate merge
  945. END_OF_FILE
  946. if test 504 -ne `wc -c <'makefile'`; then
  947.     echo shar: \"'makefile'\" unpacked with wrong size!
  948. fi
  949. # end of 'makefile'
  950. fi
  951. if test -f 'merge.c' -a "${1}" != "-c" ; then 
  952.   echo shar: Will not clobber existing file \"'merge.c'\"
  953. else
  954. echo shar: Extracting \"'merge.c'\" \(556 characters\)
  955. sed "s/^X//" >'merge.c' <<'END_OF_FILE'
  956. X/*
  957. X**  This program will read two bitmap file for exactly the 
  958. X**  same format and create a or'd version on standard output
  959. X** 
  960. X**  This use is to merge rotated crabs to find the minimal mask
  961. X*/
  962. X
  963. X#include <stdio.h>
  964. X
  965. Xmain(argc, argv)
  966. X int argc;
  967. X char *argv[];
  968. X{
  969. X  char c1, c2;
  970. X  FILE *file;
  971. X
  972. X  if( (file = fopen(argv[1], "r")) == NULL ) {
  973. X    fprintf(stderr,"Can't open the argument file\n");
  974. X    exit(1);
  975. X  }
  976. X  
  977. X  while( (c1=getchar()) != EOF && (c2=getc(file)) != EOF ) {
  978. X    if( c2=='*' )
  979. X      c1='*';
  980. X    putchar(c1);
  981. X  }
  982. X  fclose(file);
  983. X  return 0;
  984. X}
  985. END_OF_FILE
  986. if test 556 -ne `wc -c <'merge.c'`; then
  987.     echo shar: \"'merge.c'\" unpacked with wrong size!
  988. fi
  989. # end of 'merge.c'
  990. fi
  991. if test -f 'rotate.c' -a "${1}" != "-c" ; then 
  992.   echo shar: Will not clobber existing file \"'rotate.c'\"
  993. else
  994. echo shar: Extracting \"'rotate.c'\" \(614 characters\)
  995. sed "s/^X//" >'rotate.c' <<'END_OF_FILE'
  996. X/*
  997. X** This program filters a small file such that the output
  998. X** is rotated 90 degrees
  999. X**  NOTE the file must be a rectangle to work and no tabs
  1000. X*/
  1001. X
  1002. X#include <stdio.h>
  1003. X
  1004. Xchar            file[100][100];
  1005. Xint             linelen, numlines;
  1006. X
  1007. Xmain()
  1008. X{
  1009. X  int             i,j;
  1010. X  char    c;
  1011. X
  1012. X  linelen = 0;
  1013. X  numlines = 0;
  1014. X  while (gets(&file[numlines][0]) != NULL && numlines < 99) {
  1015. X    if ((i = strlen(&file[numlines][0])) > linelen)
  1016. X      linelen = i;
  1017. X    numlines++;
  1018. X  }
  1019. X  for (i = linelen-1; i >= 0; i--) {
  1020. X    for( j=0; j <numlines; j++ ){
  1021. X      putchar((c=file[j][i])?c:' ');
  1022. X    }
  1023. X    putchar('\n');
  1024. X  }
  1025. X  return 0;
  1026. X}
  1027. END_OF_FILE
  1028. if test 614 -ne `wc -c <'rotate.c'`; then
  1029.     echo shar: \"'rotate.c'\" unpacked with wrong size!
  1030. fi
  1031. # end of 'rotate.c'
  1032. fi
  1033. echo shar: End of archive 1 \(of 1\).
  1034. cp /dev/null ark1isdone
  1035. MISSING=""
  1036. for I in 1 ; do
  1037.     if test ! -f ark${I}isdone ; then
  1038.     MISSING="${MISSING} ${I}"
  1039.     fi
  1040. done
  1041. if test "${MISSING}" = "" ; then
  1042.     echo You have the archive.
  1043.     rm -f ark[1-9]isdone
  1044. else
  1045.     echo You still need to unpack the following archives:
  1046.     echo "        " ${MISSING}
  1047. fi
  1048. ##  End of shell archive.
  1049. exit 0
  1050. -- 
  1051. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1052. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1053. Post requests for sources, and general discussion to comp.sys.amiga.
  1054.